import recast from 'recast'

let code = `
  function add (x, y) {
    return x + y + 10;
  }
`

let ast = recast.parse(code);

const add = ast.program.body[0];

const b = recast.types.builders;

ast.program.body[0] = b.importDeclaration(
  [
    b.importSpecifier(b.identifier("some"), b.identifier("some")),
    b.importNamespaceSpecifier(b.identifier("va")),
    b.importDefaultSpecifier(b.identifier("va2"))
  ],
  b.literal("va")
)

ast.program.body[1] = b.importDeclaration(
  [
    b.importSpecifier(b.identifier("max"), b.identifier("max")),
    b.importNamespaceSpecifier(b.identifier("math")),
    b.importDefaultSpecifier(b.identifier("math2"))
  ],
  b.literal("va")
)

ast.program.body[2] = b.variableDeclaration("var", [
  b.variableDeclarator(add.id, b.functionExpression(
    null, // Anonymize the function expression.
    add.params,
    add.body
  ))
]);

add.params.push(add.params.shift());

console.log(add)

recast.visit(ast, {
  visitImportDeclaration: function(path) {
    console.log(path)
    path.value.source.value = 'ling'

    return false
  }
});

const output = recast.prettyPrint(ast, { tabWidth: 2 }).code;

console.log(output);